-
Notifications
You must be signed in to change notification settings - Fork 37
Add option to remove source cell contributions post-weight generation #444
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…t_s2d method
* BaseRegridder / Regridder:
- Adding new argument 'post_mask_source'
* smm module:
- new function 'mask_source_indices' altering the weights by
removing the contribution of selected source grid cells
- new function 'gen_mask_from_weights' allowing to generate
a 2D binary mask out of regridding weights
* util module:
- new function _get_edge_indices_2d, returning array of the indices
of cells at the edges of a (raveled) 2D grid
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
for more information, see https://pre-commit.ci
aulemahal
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! This looks like a great addition!
Could you add a section to the changelog ? I think you can start a new 0.9.0 (unreleased) section.
|
@aulemahal Thanks for the review. I updated the changelog for both PRs, but it seems If it is ok with you, could you merge any of the two PRs into master, and then I would resolve the merge conflicts in the other PR, as I have already resolved those locally? Here is the error traceback with |
|
Indeed, when reviewing your PR I noticed the cf-xarray error. I opened #453 to skip the failing test. I think the buggy case is narrow enough, we didn't need to pin cf-xarray in the dependencies. Doing it like you did in the CI is another similar solution. I'll try to merge my PR first and then both of yours, removing the pin. |
This is a more lightweight approach to what I tried to achieve in #317
When remapping to a larger domain with the method
nearest_s2d, data points outside the original domain will - by the nature of this method - be extrapolated, i. e. have values from the edge of the original domain.This PR introduces a Regridder option I labeled
post_mask_source:This is useful when remapping data on regional grids such as CORDEX data. A demonstration can be seen here at the bottom of
Curvilinear_grid.ipynb:https://nbviewer.org/github/sol1105/xESMF/blob/domain_mask_nearest/doc/notebooks/Curvilinear_grid.ipynb#Undesired-extrapolation
I added it as an option to the Regridder and BaseRegridder and re-arranged some of the masking steps for the parallel option to make it compatible. Beside the CORDEX use case (
post_mask_source="domain_edge"), I allowed to specify arbitrary source cells to be masked as well, while I do not have a use case for this on the top of my head. I did not lock this option tonearest_s2donly, but also here I do not have a use case in mind.From #317 I added the function to create a mask from remapping weights to
smm.py. I added an example to the documentation for that as well.Example:
Source:

Before:

After (

post_mask_source="domain_edge"):